import { createMemoryHistory, createRouter, RouteRecordRaw } from "vue-router";

const routes = [
    {
        path: '',
        component: () => import('@/views/index.vue'),
        redirect: { name: 'Home' },
        children: [
            {
                path: 'home',
                name: 'Home',
                component: () => import('@/views/home/index.vue')
            },
            {
                path: 'my',
                name: 'My',
                component: () => import('@/views/my/index.vue')
            }
        ]
    },
    {
        path: '/my',
        children: [
            {
                path: 'login',
                component: () => import('@/views/my/login/index.vue')
            },
            {
                path: 'register',
                component: () => import('@/views/my/register/index.vue')
            },
            {
                path: 'setting',
                component: () => import('@/views/my/setting/index.vue')
            }
        ]
    },
    {
        path: '/class',
        children: [
            {
                path: 'create',
                name: 'ClassCreate',
                component: () => import('@/views/home/class/create/index.vue')
            },
            {
                path: 'home',
                name: 'ClassHome',
                component: () => import('@/views/home/class/home/index.vue')
            },
            {
                path: 'join',
                name: 'ClassJoin',
                component: () => import('@/views/home/class/join/index.vue')
            }
        ]
    },
    {
        path: '/device',
        children: [
            {
                path: 'info',
                name: 'DeviceInfo',
                component: () => import('@/views/device/info/index.vue')
            }
        ]
    },
    {
        path: '/repair',
        name: 'Repair',
        component: () => import('@/views/repair/index.vue')
    },
    {
        path: '/feedback',
        name: 'Feedback',
        component: () => import('@/views/feedback/index.vue')
    }
] as Readonly<RouteRecordRaw[]>;

export const router = createRouter({
    history: createMemoryHistory(),
    routes: routes,
});